<include file="Base/header" />
    <style type="text/css">
        input[type='checkbox']{
            margin:auto 5px;
        }
    </style>
<div class="page-container">
	<include file="Base/menu" />
	<div class="page-content">
		<div class="container-fluid">
			<div class="row-fluid">
					<div class="span12">
						<h3 class="page-title">
						</h3>
						<ul class="breadcrumb">
							<li>
								<i class="icon-home"></i>
								<a href="#">首页</a>
								<i class="icon-angle-right"></i>
							</li>
							<li><a href="#">权限管理</a></li>
						</ul>
						<!-- END PAGE TITLE & BREADCRUMB-->
					</div>
			</div>
			<div class="row-fluid">
					<div class="span12">
						<!-- BEGIN EXAMPLE TABLE PORTLET-->
						<div class="portlet box blue">
							<div class="portlet-title">
								<div class="caption"><i class="icon-globe"></i>权限列表</div>
								<div class="tools">
									<a href="javascript:;" class="collapse"></a>
									<a href="javascript:;" class="reload"></a>
									<a href="javascript:;" class="remove"></a>
								</div>
							</div>
							<div class="portlet-body">
							<div class="container-fluid">
							<div id="sample_1_wrapper" class="dataTables_wrapper form-inline" role="grid">

							<div class="container-fluid">
        <form action="" method="post">
            <foreach name="data" item="v">
                <div style="margin:5px;border-bottom:1px dotted #ccc">
                    <button type="button" class="btn btn-primary">{$v['title']}</button>
                    <input type="checkbox" name="access[]" class="level1" value="{$v['id']}" <?php if(in_array($v['id'], $ids))echo "checked"?>>
                    <foreach name="v['child']" item="con">
                        <div style="margin:5px;border-top:1px solid #555">
                            <button type="button" class="btn btn-success">{$con['title']}</button>
                            <input type="checkbox" name="access[]" class="level2" value="{$con['id']}" <?php if(in_array($con['id'], $ids))echo "checked"?>>
                        </div>
                        <div style="margin:5px;">
                            <foreach name="con['child']" item="act">
                                <button type="button" class="btn btn-info" >{$act['title']}</button>
                                <input type="checkbox" name="access[]" class="level3" value="{$act['id']}" <?php if(in_array($act['id'], $ids))echo "checked"?>>
                            </foreach>
                        </div>
                    </foreach>
                </div>
            </foreach>
            <input type="hidden" name="id" value="{$id}">
            <button style="margin-left:10px" type="submit" class="btn btn-default"><i class="icon-ok"></i>保存</button>
        </form>
    </div>
						</div>

							</div>
							</div>
						</div>
						<!-- END EXAMPLE TABLE PORTLET-->
					</div>
				</div>
		</div>
	</div>
</div>
<script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
<!-- <script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> -->
<script type="text/javascript">
        $(function(){
            $('.level1').click(function(){
                if($(this).prop('checked')){
                    $(this).parent().find("input[type='checkbox']").prop('checked',true);
                }else{
                    $(this).parent().find("input[type='checkbox']").prop('checked',false);
                }   
            })
            $('.level2').click(function(){
                if($(this).prop('checked')){
                    $(this).parent().next().find("input[type='checkbox']").prop('checked',true);
                }else{
                   $(this).parent().next().find("input[type='checkbox']").prop('checked',false); 
                }
                
            })
            $('.level3').click(function(){
                var is = $(this).prop('checked');
                if(is){
                    $(this).prop('checked',true);
                }else{
                    $(this).prop('checked',false);
                }
            })
        })
    </script>
<include file="Base/footer" />
